package com.jblv.frame.common.kafka.config;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.Properties;

/**
 * @author happyonion.yangtao
 * @version 1.0
 * @title KafkaConfigProperties
 * @projectName jblv-frame
 * @packageName com.jblv.web
 * @description
 * @date Create at 2020/4/17 13:38
 * @since jdk1.8
 */
public class KafkaConfigProperties {
    private static Properties pb = null;

    public KafkaConfigProperties() {
    }

    public static String getValue(String key) {
        return pb.getProperty(key);
    }

    static {
        String proFilePath = System.getProperty("user.dir") + File.separator + "config" + File.separator + "kafka" + File.separator + "kafka.properties";
        File file = new File(proFilePath);
        if (!file.exists()) {
            URL url = KafkaConfigProperties.class.getClassLoader().getResource("");
            proFilePath = url.getPath() + File.separator + "config" + File.separator + "kafka" + File.separator + "kafka.properties";
        }

        File pFile = new File(proFilePath);
        FileInputStream pInStream = null;

        try {
            pInStream = new FileInputStream(pFile);
            pb = new Properties();
            pb.load(pInStream);
        } catch (IOException var5) {
            var5.printStackTrace();
        }

    }
}
